<template>
  <!-- <div class="member-center">
    <div class="header">
      <div class="slider-banner banner">
        <swiper class="swiper-wrapper" :options="swiperVip" ref="mySwiper">
          <swiperSlide
            class="swiper-slide memberBg"
            :class="item.class"
            v-for="(item, index) in vipList"
            :key="index"
            :style="{ backgroundImage: 'url(' + item.image + ')' }"
          >
                       <img :src="item.icon" />
            <div class="name">{{ item.name }}</div>
            <div class="discount">
              可享受商品折扣: {{ item.discount / 10 }}折<span
                class="iconfont icon-zhekou"
              ></span>
            </div>
            <div class="nav acea-row" v-if="item.grade == grade">
              <div
                class="item"
                v-for="(val, indexn) in vipComplete"
                :key="indexn"
              >
                <div class="num">{{ val.number }}</div>
                <div>{{ val.real_name }}</div>
              </div>
            </div>
            <div class="lock" v-if="item.grade > grade">
              <span class="iconfont icon-quanxianguanlisuozi"></span
              >该会员等级尚未解锁
            </div>
            <div class="lock" v-if="item.grade < grade">
              <span class="iconfont icon-xuanzhong1"></span>已解锁更高等级
            </div>
          </swiperSlide>
        </swiper>
      </div>
    </div>
    <div class="wrapper">
      <div class="title acea-row row-between-wrapper">
        <div><span class="iconfont icon-jingyanzhi"></span>会员升级要求</div>
        <div class="num">
          <span class="current">{{ taskCount }}</span
          >/{{ vipRequire.length }}
        </div>
      </div>
      <div class="list">
        <div class="item" v-for="(item, index) in vipComplete" :key="index">
          <div class="top acea-row row-between-wrapper">
            <div class="name">
              {{ item.name
              }}<span
                class="iconfont icon-wenti"
                v-if="item.illustrate"
                @click="showGrow(item)"
              ></span>
            </div>
            <div>{{ item.finish ? "已满足条件" : "未满足条件" }}</div>
          </div>
          <div class="cu-progress">
            <div class="bg-red" :style="{ width: item.speed + '%' }"></div>
          </div>
          <div class="experience acea-row row-between-wrapper">
            <div>{{ item.task_type_title }}</div>
            <div>
              <span class="num">{{ item.new_number }}</span
              >/{{ item.number }}
            </div>
          </div>
        </div>
      </div>
    </div>
    <Recommend></Recommend>
    <div class="growthValue" :class="growthValue === false ? 'on' : ''">
      <div class="pictrue">
        <img src="@assets/images/value.jpg" /><span
          class="iconfont icon-guanbi3"
          @click="growthTap"
        ></span>
      </div>
      <div class="conter">
        {{ illustrate }}
      </div>
    </div>
    <div class="mask" :hidden="growthValue" @click="growthTap"></div>
  </div> -->

  <el-container>
      <el-header style="padding:0 0;height:136px;">
        <!-- 导航 -->
        <el-row class="header " type="flex" justify="center">
          <el-col :span="18">
            <div class="row-h acea-row row-between">
              <div class="acea-row "> 
                <el-link type="info" href="/" class="el-icon-s-home"> <p >首页</p></el-link>
              </div>
              <div class="news acea-row row-right">
                <div class="userName">
                  <el-link type="info" ><p>{{ userInfo. nickname}}</p></el-link>
                </div>
                <el-link type="info" ><p class="title">消息</p></el-link>
                <el-link type="info" href="/order/list/0"><p class="title">我的订单</p></el-link>
                <el-link type="info" href="/user" ><p class="title">个人中心</p></el-link>
              </div>
             </div>
          </el-col>
        </el-row>
        <!-- 个人中心 -->
        <el-row class="g-row" type="flex" justify="center">
          <el-col style="width:1090px; height: 100px;">
            <div class="f-left acea-row">
              <div class="image"><img :src="logoUrl" ></div>
              <p class="personal">会员体系</p>
            </div>
          </el-col>
        </el-row>

      </el-header>
        <el-container style="background-color: #fff;">
          <el-main>
            <div class="main acea-row">
              <div class="f-left">
                <div class="clearfix acea-row">
                  <div class="wrap">
                      <el-avatar  icon="el-icon-user-solid" :size="46" :src="userInfo.avatar"></el-avatar>
                  </div>
                  <div class="nickName">{{ userInfo. nickname}}</div>
                </div>
                <div class="rank"> {{ explain }}</div>
                <div class="score">
                    <div class="s-line">每月3号更新</div>
                  <div class="s-line">可享受商品折扣: {{ discount / 10 }}折</div>
                  <!-- <div class="s-line">当前积分:{{userInfo.integral}}</div> -->
                </div>
                <hr style="height: 1px;margin-top: 22px;border-top: 1px solid rgba(255,255,255,.1);"/>
                <div class="bntGroup">
                  <div class="bnt">我的积分</div>
                  <div class="bnt">我的超级会员</div>
                </div>
              </div>
              <div class="f-right">
                <div class="r-header">会员专享权利</div>
                <div class="r-list ">
                  <div class="item acea-row ">
                    <div class="i-center">
                        <div class="icon "><span class="el-icon-refresh"></span></div>
                        <div class="fontName">30天无忧退货</div>
                    </div>
                  </div>
                  <div class="item acea-row ">
                      <div class="i-center">
                          <div class="icon"><span class="el-icon-box"></span></div>
                          <div class="fontName">上门取件</div>
                      </div>
                  </div>
                  <div class="item acea-row ">
                      <div class="i-center">
                          <div class="icon"><span class="el-icon-coin"></span></div>
                          <div class="fontName">邀请返利</div>
                      </div>
                  </div>
                  <div class="item acea-row ">
                      <div class="i-center">
                          <div class="icon"><span class="el-icon-present"></span></div>
                          <div class="fontName">升级礼包</div>
                      </div>
                  </div>
                  <div class="item acea-row ">
                      <div class="i-center">
                          <div class="icon"><span class="el-icon-s-ticket"></span></div>
                          <div class="fontName">每月礼券</div>
                      </div>
                  </div>
                  <div class="item acea-row ">
                      <div class="i-center">
                          <div class="icon"><span class="el-icon-location-outline"></span></div>
                          <div class="fontName">品牌线下活动</div>
                      </div>
                  </div>
                  <div class="item acea-row ">
                      <div class="i-center">
                          <div class="icon"><span class="el-icon-service"></span></div>
                          <div class="fontName">优先客服</div>
                      </div>
                  </div>
                  <div class="item acea-row ">
                      <div class="i-center">
                          <div class="icon"><span class="el-icon-more"></span></div>
                          <div class="fontName">更多特权敬请期待</div>
                      </div>
                  </div>
                </div>
              </div>
            </div>
          </el-main>
        <el-footer style="padding: 0;">
        <Foot></Foot>
        </el-footer>
      </el-container>
    </el-container>
</template>
<script>
// import { swiper, swiperSlide  } from "vue-awesome-swiper";
// import "@assets/css/swiper.min.css";
import Recommend from "@components/Recommend";
import Foot from "@components/Foot";
import { getHomeData } from "@api/public";
import { getVipInfo, getVipTask, setDetection ,getUser} from "../../api/user";
export default {
  name: "Poster",
  components: {
    // swiper,
    // swiperSlide,
    Recommend,
    Foot
  },
  props: {},
  data: function() {
    return {
      vipList: [], //等级列表
      vipRequire: [], //等级要求
      vipComplete: [], //完成情况
      taskCount: 0, //任务数
      grade: 0, //当前会员等级
      explain:"",//当前会员名称
      discount:"",//当前折扣
      userInfo: {},
      swiperVip: {
        speed: 1000,
        effect: "coverflow",
        slidesPerView: "auto",
        centeredSlides: true,
        // loop: true,
        coverflowEffect: {
          rotate: 0, // 旋转的角度
          stretch: -20, // 拉伸   图片间左右的间距和密集度
          depth: 100, // 深度   切换图片间上下的间距和密集度
          modifier: 2, // 修正值 该值越大前面的效果越明显
          slideShadows: false // 页面阴影效果
        },
        observer: true,
        observeParents: true
      },
      logoUrl:"",
      loading: false,
      growthValue: true,
      illustrate: "",
      activeIndex: 0
    };
  },
  watch: {
    vipList: function() {
      let that = this;
      if (that.vipList.length > 0) {
        that.vipList.forEach(function(item, index) {
          if (item.is_clear === false) {
            // that.swiper.slideTo(index);
            that.activeIndex = index;
            that.grade = item.grade;
            that.explain=item.explain;
            that.discount=item.discount
            console.log("that.grade:"+that.grade)
          }
        });
      }
    }
  },
  computed: {
    // swiper() {
    //   return this.$refs.mySwiper.swiper;
    // }
  },
  mounted: function() {
    let that = this;
      getHomeData().then(res => {
         that.logoUrl = res.data.logoUrl;
       });
    that.User();
    setDetection();
    that.getInfo();
    // that.swiper.on("slideChange", function() {
    //   that.activeIndex = that.swiper.activeIndex;
    //   that.getTask();
    // });
  },
  methods: {
    growthTap: function() {
      this.growthValue = true;
    },
    User: function() {
      let that = this;
      getUser().then(res => {
        that.userInfo = res.data;
      });
    },
    getInfo: function() {
      let that = this;
      getVipInfo().then(
        res => {
          that.vipList = res.data.list;
          that.vipRequire = res.data.task.list;
          that.vipComplete = res.data.task.task;
          that.taskCount = res.data.task.reach_count;
        },
        err => {
          that.$dialog.message(err.msg);
        }
      );
    },
    getTask: function() {
      let that = this;
      getVipTask(that.vipList[that.activeIndex].id).then(
        res => {
          that.vipRequire = res.data.list;
          that.vipComplete = res.data.task;
          that.taskCount = res.data.reach_count;
        },
        err => {
          that.$dialog.message(err.msg);
        }
      );
    },
    showGrow: function(item) {
      if (this.illustrate != item.illustrate) this.illustrate = item.illustrate;
      this.growthValue = false;
    }
  }
};
</script>
<style scoped>
   .main {
      background-color: #fff;
      width:1092px;
      margin: 0 auto;
      margin-top: 90px;
      height: 322px;
    }
    .main .f-left {
      width: 260px;
      height: 320px;
      background-color:#D2B984;
      border-top-left-radius: 30px;
    }
    .main .f-left  .clearfix {
      height: 60px;
      width: 260px;
      padding: 5px;
    }
    .main .f-left  .clearfix .wrap {
      width: 46px;
      height: 46px;
    }
    .main .f-left  .clearfix .nickName {
      width: 144px;
      height: 50px;
      margin: 0 12px;
      text-overflow: ellipsis;
      overflow: hidden;
      white-space: nowrap;
      color: #fff;
      text-align: center;
      font-size: 18px;
      line-height: 50px;
    }
    .main .f-left .rank {
      width: 260px;
      height: 32px;
      margin: 26px 0 13px;
      color: #fff;
      text-align: center;
      font-family: "Microsoft Yahei","微软雅黑",verdana;
      font-size: 32px;
      line-height: 32px;
    }
    .main .f-left .score {
      width: 260px;
      height: 36px;
    }
    .main .f-left .score .s-line {
      font-family: "Microsoft Yahei","微软雅黑",verdana;
      color: #fff;
      text-align: center;
      font-size: 14px;
    }
    .main .f-left  .bntGroup {
      width: 260px;
      height: 76px;
      margin: 21px 0 0;
    }
    .main .f-left  .bntGroup  .bnt {
      width: 178px;
      height: 32px;
      border-radius: 100px;
      line-height: 32px;
      color: #b4a078;
      font-size: 14px;
      background-color: #f5f5f5;
      text-align: center;
      margin: 0 auto;
      margin-bottom: 12px;
      cursor: pointer;
    }
    .main .f-right {
      width: 830px;
      height: 320px;
      border: 1px solid #e1d9c9;
    }
    .main .f-right .r-header {
      width: 830px;
      height: 60px;
      padding: 28px 20px 0;
      border-bottom: 1px solid #e1d9c9;
      color: #b4a078;
      font-size: 20px;
      line-height: 1;
    }
    .main .f-right .r-list {
      height: 290px;
      margin: 0 29px;
    }
    .main .f-right .r-list .item {
      width: 192px;
      height: 129px;
      display: inline-block;
    }
    .main .f-right .r-list .item .i-center {
      padding-top: 17.5px;
    }
    .main .f-right .r-list .item .icon {
      width: 50px;
      height: 50px;
      margin: 0 auto;
      font-size: 50px;
      color: rgb(210,185,132);
      font-weight: 700;
    }
    .main .f-right .r-list .item  .fontName {
      height: 44px;
      font-size: 16px;
      color: #666666;
      padding-top: 5px;
      font-family: "Microsoft Yahei","微软雅黑",verdana;
      line-height: 34px;
      text-align: center;
    }
    
   .g-row .f-left .personal {
    display: inline-block;
    padding-left: 17px;
    margin-left: 20px;
    font-size: 24px;
    line-height: 30px;
    font-weight: 400;
    color: #CC9756;
    border-left: 1px solid #CC9756;
    vertical-align: middle;

   }
   .g-row .f-left .image  img {
     width: 100%;
     height: 100%;
   }
   .g-row .f-left .image {
     width: 126px;
     height: 30px;
  }
  .g-row .f-left {
    width: 260px;
    height: 30px;
    margin-top:35px;
  }
  .g-row {
   height: 100px;
   border-bottom:1px solid #ccc ;
   box-shadow: 0 2px 5px rgba(0, 0, 0, .1);
   background-color: #fff;
 }
 .header {
  height: 36px;
  background-color: #333;
 }
 .header  .row-h {
   width: 1090px;
   margin: 0 auto;
 }
 .header  .home {
   font-size: 12px;
 }
  .header .userName  {
    width: 90px;
    height: 36px;
    margin-right: 10px;
    padding: 0 5px
  }
  .header .userName p{
    width: 70px;
    font-size: 12px;
    text-align: center;
    line-height: 36px;
    overflow: hidden;
    text-overflow:ellipsis;
    white-space: nowrap;
  }
  .header .title {
   font-size: 12px;
   border-left:1px solid #ccc ;
   padding: 0 10px;
 }
</style>